package com.techsoul.module.accounting.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.techsoul.module.accounting.pojo.entity.AccountingAp;
import com.techsoul.module.accounting.pojo.param.AccApSkuMonthlySettlementSearchParam;
import com.techsoul.module.accounting.pojo.param.AccountingApSearchParam;
import com.techsoul.module.accounting.pojo.vo.AccountingApViewVo;
import com.techsoul.module.accounting.pojo.vo.AccountingApVo;
import com.techsoul.module.order.pojo.entity.SalesOrderItem;
import com.techsoul.module.order.pojo.param.SalesOrderItemSearchParam;
import com.techsoul.module.order.pojo.vo.SalesOrderItemBrandRateViewVo;
import com.techsoul.module.order.pojo.vo.SalesOrderItemSupplierRateViewVo;
import com.techsoul.module.pms.pojo.vo.CustGoodsMapVo;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 财务应付Mapper接口
 * 
 * @author liuen
 * @date 2021-04-11
 */
public interface AccountingApMapper extends BaseMapper<AccountingAp> {

    /**
     * 详情
     * @param id
     * @return
     */
    AccountingApVo findById(String id);
    List<AccountingAp> findByOrderItemNo(String orderItemNo);

    /**
     * 列表
     * @param params
     * @return
     */
    List<AccountingApVo> findAll(@Param("params") AccountingApSearchParam params);

    /**
     * 列表字段汇总
     * @param params
     * @return
     */
    AccountingApVo sum(@Param("params") AccountingApSearchParam params);
    /**
     * 退单列表字段汇总
     * @param params
     * @return
     */
    AccountingApVo returnSum(@Param("params") AccountingApSearchParam params);

    /**
     * 报表字段汇总
     * @param params
     * @return
     */
    AccountingApVo settlementViewMonthlySum(@Param("params") AccountingApSearchParam params);

    /**
     * 报表字段汇总
     * @param params
     * @return
     */
    AccountingApVo settlementViewMonthlyReturnSum(@Param("params") AccountingApSearchParam params);

    /**
     *供应商查看列表
     * @param supplierNo
     *   @param dateFrom
     * @return
     */
    List<AccountingApVo> suppierViewAccountBetween(@Param("supplierNo") String supplierNo,@Param("dateFrom") String dateFrom,@Param("dateTo") String dateTo);

    /**
     *供应商查看列表
     * @param supplierNo
     *   @param dateFrom
     * @return
     */
    List<AccountingApVo> suppierViewAccount(@Param("supplierNo") String supplierNo,@Param("dateFrom") String dateFrom);

    /**
     *供应商查看列表
     * @param supplierNo
     *   @param dateFrom
     * @return
     */
    List<AccountingApVo> suppierViewAccountDateFrom(@Param("supplierNo") String supplierNo,@Param("dateFrom") String dateFrom);

    /**
     *供应商查看列表
     * @param supplierNo
     *   @param dateTo
     * @return
     */
    List<AccountingApVo> suppierViewAccountDateTo(@Param("supplierNo") String supplierNo,@Param("dateTo") String dateTo);
    /**
     * 分页
     * @param page
     * @param params
     * @return
     */
    IPage<AccountingApVo> findAll(Page page, @Param("params") AccountingApSearchParam params);
    /**
     * 分页
     * @param page
     * @param params
     * @return
     */
    IPage<AccountingApVo> findAllWithRt(Page page, @Param("params") AccountingApSearchParam params);

    /**
     * 报表分页
     * @param page
     * @param params
     * @return
     */
    IPage<AccountingApVo> settlementViewMonthly(Page page, @Param("params") AccountingApSearchParam params);
    /**
     * 采购报表分页
     * @param page
     * @param params
     * @return
     */
    IPage<AccountingApVo> settlementViewSkuMonthly(Page page, @Param("params") AccountingApSearchParam params);


    /**
     * 报表
     *
     * @param params
     * @return
     */
    List<AccountingApVo>  settlementViewMonthly(@Param("params") AccountingApSearchParam params);
    /**
     * 供应商汇总
     *
     * @param params
     * @return
     */
    IPage<AccountingApVo> supplierSumPage(Page page, @Param("params") AccountingApSearchParam params);


    /**
     * 汇总
     * @param params
     * @return
     */
    List<AccountingApVo> findSumAps(@Param("params") AccApSkuMonthlySettlementSearchParam params);

    /**
     * 退单汇总
     * @param params
     * @return
     */
    List<AccountingApVo> findSumReturns(@Param("params") AccApSkuMonthlySettlementSearchParam params);
    /**
     * 品牌排行分页
     * @param page
     * @param params
     * @return
     */
    IPage<AccountingApVo> brandRateView(Page page, @Param("params") AccountingApSearchParam params);

    /**
     * 供应商分页
     * @param page
     * @param params
     * @return
     */
    IPage<AccountingApVo> supplierRateView(Page page, @Param("params") AccountingApSearchParam params);

    void updateStatusToSettled(@Param("monthYear") String monthYear);

    IPage<AccountingApVo> skuReportToAllStore(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportTo(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportFrAllStore(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportFr(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportStoreAll(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportStore(Page page, @Param("params") AccountingApSearchParam params);

    IPage<AccountingApVo> skuReportFrAllSpu(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportToAllSpu(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApVo> skuReportStoreAllSpu(Page page, @Param("params") AccountingApSearchParam params);

    IPage<AccountingApViewVo> spuReport(Page page, @Param("params") AccountingApSearchParam params);
    IPage<AccountingApViewVo> skuReport(Page page, @Param("params") AccountingApSearchParam params);
    /**
     * 采购额 当天按区域查询
     * @param params
     * @return
     */
    AccountingApVo countTotalTodayPurchase(@Param("params") AccountingApSearchParam params);
    /**
     * 销售额 当天按区域查询
     * @param params
     * @return
     */
    AccountingApVo countTotalTodaySale(@Param("params") AccountingApSearchParam params);

    List<AccountingAp> findByCustSalesOrderItemNoAndOrProductSkuCode(@Param("itemNo") String itemNo, @Param("skuNo") String skuNo, @Param("spuNo") String spuNo);

    /**
     * 查询重复的数据
     * @return
     */
    List<Map<String, String>> findDistinct();
}
